/*
 * docs.js
 *
 * Copyright (C) 2006 - OS3 srl - http://www.os3.it
 *
 * Written by: Fabio Rotondo - fabio.rotondo@os3.it
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation;
 * version 2 of the License ONLY.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * NOTE: this is the GPL version of the library. If you want to include this 
 *       library inside a CLOSED SOURCE / PROPRIETARY software, you need 
 *       to purchase a COMMERCIAL LICENSE. See http://www.os3.it/license/
 *       for more info.
 */
var docs = {};

docs.nodes = {};

docs.init = function ()
{
	var s;
	var lb;

	lb = document.getElementById ( "leftbar" );
	lb.innerHTML = docs._gather_links ();
};

docs._gather_links = function ()
{
	var links = document.getElementsByTagName ( 'a' );
	var l, t, lnk;
	var s = '<input id="show_only_one" type="checkbox" \/>Show only one item<br \/>';
	var linked = {};
	var first_node = null;

	l = links.length;

	for ( t = 0; t < l; t ++ )
	{
		lnk = links [ t ];
		if ( ! lnk.title ) continue;
		if ( linked [ lnk.name ] ) continue;

		linked [ lnk.name ] = 1;
		docs.nodes [ lnk.name ] = lnk;

		if ( ! first_node ) first_node = lnk;

		lnk.parentNode.style.display = 'none';

		s += '<a href="#" onclick="docs.show(\'' + lnk.name + '\')">' + lnk.title + '<\/a><br \/>';
	}

	first_node.parentNode.style.display = 'block';

	return s;
};

docs.show = function ( lnk_name )
{
	var lnk = docs.nodes [ lnk_name ];

	if ( document.getElementById ( "show_only_one" ).checked ) docs._hide_all ();

	if ( lnk.parentNode.style.display == 'block' )
		lnk.parentNode.style.display = 'none';
	else
		lnk.parentNode.style.display = 'block';
};

docs._hide_all = function ()
{
	for ( var n in docs.nodes )
	{
		if ( typeof ( docs.nodes [ n ] ) == 'function' ) continue;
		docs.nodes [ n ].parentNode.style.display = 'none';
	}
};


